{extend name="layout" /}
{block name="body"}
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body">
                <form action="#!" method="post" name="edit-form" class="edit-form">
                    <div class="form-group">
                        <label for="site_title">网站标题</label>
                        <input type="hidden" value="{$data.id}" id="id">
                        <input class="form-control" type="text" id="site_title" name="site_title"
                            value="{$data.site_title}" placeholder="请输入站点标题">
                    </div>
                    <div class="form-group">
                        <label for="site_keywords">站点关键词</label>
                        <input class="form-control" type="text" id="site_keywords" name="site_keywords"
                            value="{$data.site_keywords}" placeholder="请输入站点关键词">
                        <small class="help-block">网站搜索引擎关键字</small>
                    </div>
                    <div class="form-group">
                        <label for="site_description">站点描述</label>
                        <textarea class="form-control" id="site_description" rows="5" name="site_description"
                            placeholder="请输入站点描述">{$data.site_description}</textarea>
                        <small class="help-block">网站描述，有利于搜索引擎抓取相关信息</small>
                    </div>
                    <div class="form-group">
                        <label for="copyright_information">版权信息</label>
                        <input class="form-control" type="text" id="copyright_information" name="copyright_information"
                            value="{$data.copyright_information}" placeholder="请输入版权信息">
                    </div>
                    <div class="form-group">
                        <label for="filing_information">备案信息</label>
                        <input class="form-control" type="text" id="filing_information" name="filing_information"
                            value="{$data.filing_information}" placeholder="请输入备案信息">
                    </div>
                    <div class="form-group">
                        <label for="template">模板文件</label>
                        <select class="form-control" id="template">
                            <option value="" disabled>请选择模板文件</option>
                            {foreach :getDir() as $key=>$value }
                            <option value="{$value}" {if $value==$data.template}selected{/if}>{$value}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div class="form-group file-group">
                        <label for="pic1">应用图片</label>
                        <div class="input-group">
                            <input type="text" class="form-control file-value" value="{$data.pic1}" id="pic1"
                                value="" placeholder="应用图标" />
                            <input type="file" name="file" accaccept=".png,.jpg,.jpeg,.bmp,.gif" class="hidden"
                                style="display: none;" />
                            <div class="input-group-btn">
                                <button class="btn btn-default file-browser" type="button">上传图片</button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group file-group">
                        <label for="pic2">应用图片</label>
                        <div class="input-group">
                            <input type="text" class="form-control file-value" value="{$data.pic2}" id="pic2"
                                value="" placeholder="应用图标" />
                            <input type="file" name="file" accaccept=".png,.jpg,.jpeg,.bmp,.gif" class="hidden"
                                style="display: none;" />
                            <div class="input-group-btn">
                                <button class="btn btn-default file-browser" type="button">上传图片</button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group file-group">
                        <label for="pic3">应用图片</label>
                        <div class="input-group">
                            <input type="text" class="form-control file-value" value="{$data.pic3}" id="pic3"
                                value="" placeholder="应用图标" />
                            <input type="file" name="file" accaccept=".png,.jpg,.jpeg,.bmp,.gif" class="hidden"
                                style="display: none;" />
                            <div class="input-group-btn">
                                <button class="btn btn-default file-browser" type="button">上传图片</button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group file-group">
                        <label for="pic4">应用图片</label>
                        <div class="input-group">
                            <input type="text" class="form-control file-value" value="{$data.pic4}" id="pic4"
                                value="" placeholder="应用图标" />
                            <input type="file" name="file" accaccept=".png,.jpg,.jpeg,.bmp,.gif" class="hidden"
                                style="display: none;" />
                            <div class="input-group-btn">
                                <button class="btn btn-default file-browser" type="button">上传图片</button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group file-group">
                        <label for="pic5">应用图片</label>
                        <div class="input-group">
                            <input type="text" class="form-control file-value" value="{$data.pic5}" id="pic5"
                                value="" placeholder="应用图标" />
                            <input type="file" name="file" accaccept=".png,.jpg,.jpeg,.bmp,.gif" class="hidden"
                                style="display: none;" />
                            <div class="input-group-btn">
                                <button class="btn btn-default file-browser" type="button">上传图片</button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="appid">appid</label>
                        <select class="form-control" id="appid" disabled>
                            <option value="" disabled>请选择app</option>
                            {foreach :query('app') as $key=>$value }
                            <option value="{$value['appid']}" {if $value==$value.appid}selected{/if}>
                                {$value["appname"]}(appid:{$value['appid']})</option>
                            {/foreach}
                        </select>
                    </div>
                    <div class="form-group">
                        <button type="button" id="btn" class="btn btn-primary m-r-5">确 定</button>
                        <button type="button" class="btn btn-default"
                            onclick="javascript:history.back(-1);return false;">返 回</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script>
    $("#btn").click(function () {
        var l = $('#btn').lyearloading({
            opacity: 0.2,
            spinnerSize: 'nm'
        });
        var id = $.trim($("#id").val());
        var site_title = $.trim($("#site_title").val());
        var site_keywords = $.trim($("#site_keywords").val());
        var site_description = $.trim($("#site_description").val());
        var copyright_information = $.trim($("#copyright_information").val());
        var filing_information = $.trim($("#filing_information").val());
        var template = $.trim($("#template").val());
        var pic1 = $.trim($("#pic1").val());
        var pic2 = $.trim($("#pic2").val());
        var pic3 = $.trim($("#pic3").val());
        var pic4 = $.trim($("#pic4").val());
        var pic5 = $.trim($("#pic5").val());
        $.ajax({
            type: 'post',
            url: "{:url('Appdown/edit')}",
            data: {
                'id': id,
                'site_title': site_title,
                'site_keywords': site_keywords,
                'site_description': site_description,
                'copyright_information': copyright_information,
                'filing_information': filing_information,
                'template': template,
                'pic1': pic1,
                'pic2': pic2,
                'pic3': pic3,
                'pic4': pic4,
                'pic5': pic5,
            },
            dataType: "json",
            success: function (data) {
                l.destroy();
                if (data.code == 1) {
                    notify.success(data.msg, function () {
                        location.reload();
                    }, 1000);
                } else {
                    notify.error(data.msg);
                }
            },
            error: function () {
                l.destroy();
                notify.error("系统错误");
            }
        })
    });
</script>
{/block}